<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="hello.js"></script> -->
</head>
<body>
    <!-- <input type="button" value="JavaScript样例" onclick="alert('hello world!')"> -->
    <!-- <script>
        alert('hahahahahah')
    </script> -->
    <!-- <script>
        prompt('请输入你的名字')
    </script> -->
    <!-- <script>
        alert('你好')
    </script> -->
    <!-- <script>
        let name = prompt('请输入您的名字：');
        alert('你好' + name);
    </script> -->
    <!-- <script>
        var a = 10;
        console.log('a的数据类型为：' + typeof(a));
        a = 'haha';
        console.log('a的数据类型为：' + typeof(a));
    </script> -->
    <!-- <script>
        let num = 1;
        console.log('num的数据类型：' + typeof(num))
        num = 3.14
        console.log('num的数据类型：' + typeof(num))
    </script> -->
    <!-- <script>
        let num = 0o1237
        console.log(num)
        num = 0x123a
        console.log(num)
        num = 0b010101
        console.log(num)
    </script> -->
    <!-- <script>
        let num = Number.MAX_VALUE //得到Number所能表示的最大范围
        console.log(num)
        console.log(num * 2) //超过了Number能表示的最大范围，所以得到Infinity
        console.log(-num * 2)
        console.log('haha' - 10) //得到NaN
    </script> -->
    <!-- <script>
        let s = '你好'
        console.log('s的数据类型' + typeof(s))
        s = "hello"
        console.log('s的数据类型' + typeof(s))
        s = haha //报错
        console.log('s的数据类型' + typeof(s))
    </script> -->
    <!-- <script>
        console.log("女神对我说：'我爱你'")
        console.log('女神对我说："我爱你"')
        console.log("女神对我说：\"我爱你\"")
        console.log('女神对我说：\'我爱你\'')
    </script> -->
    <!-- <script>
        let num = 'hello'
        console.log('num的长度为：' + num.length)
        num = '你好'
        console.log('num的长度为：' + num.length)
    </script> -->
    <!-- <script>
        let s1 = 'hello '
        let s2 = 20
        console.log(s1 + s2)
    </script> -->
    <!-- <script>
        console.log(true + 1);
        console.log(false + 1)
    </script> -->
    <!-- <script>
        let val;
        console.log("val的数据类型是：" + typeof(val));
        val = 'abc'
        console.log("val的数据类型是：" + typeof(val)); //对变量赋值之后就可以确定变量的数据类型了
    </script> -->
    <!-- <script>
        let val;
        console.log(val + 10);
    </script> -->
    <!-- <script>
        let val = null;
        console.log(val + 10);
        console.log(val + '你好');
    </script> -->
    <!-- <script>
        let val1 = 10;
        let val2 = '10';
        console.log(val1 == val2);
        console.log(val1 === val2);
    </script> -->
    <!-- <script>
        let year = parseInt(prompt('请输入年份：'));
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            alert('闰年');
        }else {
            alert('不是闰年');
        }
    </script> -->
    <!-- <script>
        let day = parseInt(prompt('请输入数字'));
        switch(day) {
            case 1: 
                alert('星期一');
                break;
            case 2:
                alert('星期二');
                break;
            case 3:
                alert('星期三');
                break;
            case 4:
                alert('星期四');
                break;
            case 5:
                alert('星期五');
                break;
            case 6:
                alert('星期六');
                break;
            case 7:
                alert('星期日');
                break;
            default:
                alert('您输入的数字非法，请检查后重新输入！');
        }
    </script> -->
    <!-- <script>
        for (let i = 0; i < 10; i++) {
            console.log(i);
            if (i == 3) {
                break;
            }
            console.log(i);
        }
    </script> -->
    <!-- <script>
        let i = 0;
        while (i < 10) {
            console.log(i);
            if (i == 3) {
                i++;
                continue;
            }
            console.log(i);
            i++;
        }
    </script> -->
    <!-- <script>
        let arr1 = new Array(); //使用new关键字创建
        let arr2 = [] //使用字面常量创建
        let arr3 = [1,'你好'] //也可以在创建的时候就向数组中添加元素
    </script> -->
    <!-- <script>
        let arr = ['张三','李四','王五','赵六',1,2,3];
        console.log(arr);
        arr[1] = 100;
        console.log(arr)
    </script> -->
    <!-- <script>
        let arr = [1,4,3,3]
        arr.length = 6
        console.log(arr[4])
        console.log(arr[5])
    </script> -->
    <!-- <script>
        let arr = []
        arr[1] = 10
        console.log(arr[0])
        console.log(arr[1])
    </script> -->
    <!-- <script>
        let arr = [1,2,3,4,5]
        arr.push(10)
        console.log(arr)
    </script> -->
    <!-- <script>
        let arr = [1,2,3,4,5]
        arr.splice(1,3)
        console.log(arr)
    </script> -->
    <!-- <script>
        function sayHello() {
            console.log('hello');
        }
        sayHello();
    </script> -->
    <!-- <script>
        function sum(a,b) {
            return a + b;
        }
        let ret = sum(10,20) //实参和形参的个数相同
        console.log(ret)
        ret = sum(10) //实参的个数少于形参的个数
        console.log(ret)
        ret = sum(10,20,30) //实参的个数多余形参的个数
        console.log(ret)
    </script> -->
    <!-- <script>
        let sum = function(a,b) {
            return a + b;
        }
        let ret = sum(10,20);
        console.log(ret)
    </script> -->
    <!-- <script>
        function test() {
            let num = 10; //局部变量，该变量只有在test函数中才可以被访问到，出了这个函数之后就会被销毁
        }
        test();
        console.log(num);
    </script> -->
    <!-- <script>
        function test() {
            num = 10;
        }
        test();
        console.log(num);
    </script> -->
    <!-- <script>
        let num = 10;
        function test() {
            let num = 20;
            console.log(num);
        }
        test();
    </script> -->
    <!-- <script>
        let a = {} //创建一个空对象
        let student = {
            name: '张三',
            age: 18,
            sex: '男',
            sayHello: function() {
                console.log(this.name + '说：hello')
            }
        }
        console.log(student.name);
        console.log(student['age']);
        console.log(student.sex);
        let func = student['sayHello'];
        func();
    </script> -->
    <!-- <script>
        let student = new Object();
        student.name = '张三';
        student.age = 18;
        student.sex = '男';
        student.sayHello = function() {
            console.log(student.name + '说：hello');
        }
        console.log(student.name);
        console.log(student['age']);
        console.log(student.sex);
        student.sayHello();
    </script> -->
    <script>
        function Cat(name,type,sound) {
            this.name = name;
            this.type = type;
            this.sound = function() {
                console.log(sound);
            }
        }
        let huahua = new Cat('花花','狸花猫','喵');
        let mimi = new Cat('咪咪','银渐层','喵喵');
        console.log(mimi);
        mimi.sound();
    </script>
</body>
</html>